﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DCTAccess.Business.Administrator
{
    public class HistoryLogger
    {
        private static void Log(ActionHistoryTypes type, int adminID, params object[] parameters)
        {
            History.WebHistoryAdmin history = new History.WebHistoryAdmin();
            history.HistoryTypeID = (int)type;
            history.AdminID = adminID;

            switch (type)
            {
                case ActionHistoryTypes.Login:
                    history.Description = string.Format(HistoryMessages.LOGIN, parameters);
                    break;

                case ActionHistoryTypes.Logout:
                    history.Description = string.Format(HistoryMessages.LOGOUT, parameters);
                    break;
            }
        }

        public static void LogLoginAction(Administrator admin)
        {
            Log(ActionHistoryTypes.Login, admin.ID,
                    admin.FullName,
                    DateTime.Now);
        }

        public static void LogLogoutAction(Administrator admin)
        {
            Log(ActionHistoryTypes.Logout, admin.ID,
                    admin.FullName,
                    DateTime.Now);
        }       
    }
}
